#include "m0wig.h"
#include "ui_m0wig.h"

M0Wig::M0Wig(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::M0Wig)
{
    ui->setupUi(this);

    ui->pushButton_temperature->setIcon(QIcon(":/new/prefix1/newtemperature.png"));
    ui->pushButton_temperature->setIconSize(QSize(100,100));
    ui->pushButton_humidity->setIcon(QIcon(":/new/prefix1/newhumidity.png"));
    ui->pushButton_humidity->setIconSize(QSize(100,100));
    ui->pushButton_ill->setIcon(QIcon(":/eketingguangzhao.png"));
    ui->pushButton_ill->setIconSize(QSize(100,100));
    ui->pushButton_light->setIcon(QIcon(":/new/prefix1/newlight.png"));
    ui->pushButton_light->setIconSize(QSize(100,100));
    ui->pushButton_alarm->setIcon(QIcon(":/new/prefix1/newalarm.png"));
    ui->pushButton_alarm->setIconSize(QSize(100,100));
    ui->pushButton_fan->setIcon(QIcon(":/new/prefix1/newfan.png"));
    ui->pushButton_fan->setIconSize(QSize(100,100));

    connect(ui->pushButton_light,SIGNAL(clicked()),this,SLOT(m0lightkz()));
    connect(ui->pushButton_alarm,SIGNAL(clicked()),this,SLOT(m0alarmkz()));
    connect(ui->pushButton_fan,SIGNAL(clicked()),this,SLOT(m0fankz()));
    connect(ui->pushButton_sx,SIGNAL(clicked()),this,SLOT(m0sx()));

}

M0Wig::~M0Wig()
{
    delete ui;
}

void M0Wig::m0temperaturedata(QString str)
{
    ui->label_1->setText(str);
}

void M0Wig::m0humiditydata(QString str)
{
    ui->label_2->setText(str);
}

void M0Wig::m0illdata(QString str)
{
    ui->label_3->setText(str);
}

void M0Wig::m0lightkz()
{
    if(ui->label_4->text()=="off")
    {
        int ktlight=0;
        ui->label_4->setText("on");
        emit m0light(ktlight);
    }
    else if(ui->label_4->text()=="on")
    {
        int ktlight=1;
        ui->label_4->setText("off");
        emit m0light(ktlight);
    }

}
void M0Wig::m0alarmkz()
{
    if(ui->label_5->text()=="off")
    {
        int ktjg=0;
        ui->label_5->setText("on");
        emit m0alarm(ktjg);
    }
    else if(ui->label_5->text()=="on")
    {
        int ktjg=1;
        ui->label_5->setText("off");
        emit m0alarm(ktjg);
    }
}
void M0Wig::m0fankz()
{
    if(ui->label_6->text()=="off")
    {
        int ktfs=0;
        ui->label_6->setText("on");
        emit m0fan(ktfs);
    }
    else if(ui->label_6->text()=="on")
    {
        int ktfs=1;
        ui->label_6->setText("off");
        emit m0fan(ktfs);
    }
}
void M0Wig::m0sx()
{
    int index=1;
    emit shuaxin(index);
}


